package at.jaki.ubb.crawling.mvc.core;

import java.io.File;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

import at.jaki.ubb.crawling.api.CrawlingEngine;
import at.jaki.ubb.crawling.core.CrawlingEngineImpl;
import at.jaki.ubb.crawling.mvc.mock.MockDataGenerator;

public class Core {

	private static final Logger LOG = Logger.getLogger(Core.class);

	/**
	 * log4j config file location
	 */
	public static final String LOG4J = "config" + File.separatorChar + "log4j.xml";

	/**
	 * Will initialize log4J
	 */
	private static void initLog4j() {
		String log4j = LOG4J;
		DOMConfigurator.configure(log4j);
		LOG.info("Loaded log configuration from " + log4j);
	}

	/**
	 * starting point of application
	 * @param args cmd line arguments
	 */
	public static void main(String[] args) {
		initLog4j();
		CrawlingEngine ce = new CrawlingEngineImpl();
		ce.start(MockDataGenerator.createMockConfigObject1());
		ce.addTarget(MockDataGenerator.createMockTargetMediafax());
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ce.stop();
	}
}
